AddModuleConfiguration
This function allows users to add devices that auto-configuration cannot detect by overriding it.
It serves two purposes:
- Adding devices that can't be detected by auto-configuration, such as IO-Link devices, certain CANopen devices, and devices linked to the coupler.
- Overriding the EtherCAT auto-configuration. To override the auto-configuration, this function must be used before the device connects to KINGSTAR.
Syntax
KsError AddModuleConfiguration(
int SlaveId,
int ModuleId,
KsConfigurationType ConfigurationType,
VOID* Configuration
);
Parameters
SlaveId: the index of a slave array. When EtherCAT is started, this index has the same value as the SlaveId, which corresponds to the position of the slave in the network. Please note that after EtherCAT is started in the Operational (Op) state, any addition or removal of slaves from the network will change the position of the slaves in the network (SlaveId). Nevertheless, the index of the slave will remain the same. Newly added devices will be added in the back of the slave array. For all slaves after the change, the index and SlaveId will no longer match. This behavior is only available for physical devices; simulated devices are inapplicable. Please refer to the use cases in EnableHotConnect for more details.
ModuleId: the module (devices linked to the coupler) ID. It can be slot ID, port ID, or CANopen slave ID.
ConfigurationType: the type of link between the device and the coupler. See the KsConfigurationType type.
Configuration: pointer to the configuration structure. It depends on what protocol you use. For example, if it's IO-Link, the configuration is the IoLinkSetting structure.
Return value
If the function succeeds, it returns errNoError
, otherwise an error code. For more information about the error code, see the KsError list.
Remarks
This function must be called after Create and before Start.
Usable EtherCAT states
ecatOffline
Example
// configIoLink
IoLinkSetting IoLink = {
17, // IO-Link specification: Version 1.1
0, // SPDU
3, // Control
32, // Input length
0 // Output length
};
nRet = AddModuleConfiguration(
2, // EthercatSlaveID
0, // LinkedDeviceID
configIoLink, // Protocol
&IoLink // Settings
);
// configCANopen
CanOpenSetting CanOpen = { 0 };
CanOpen.RxPdoCount = 4;
CanOpen.RxPdos[0] = { TRUE, 16, 0x1800, 0xFF };
CanOpen.RxPdos[1] = { FALSE, 48, 0x1801, 0xFF };
CanOpen.RxPdos[2] = { FALSE, 48, 0x1802, 0xFF };
CanOpen.RxPdos[3] = { FALSE, 0, 0x1803, 0xFF };
CanOpen.TxPdoCount = 4;
CanOpen.TxPdos[0] = { TRUE, 16, 0x1400, 0xFF };
CanOpen.TxPdos[1] = { FALSE, 48, 0x1401, 0xFF };
CanOpen.TxPdos[2] = { FALSE, 48, 0x1402, 0xFF };
CanOpen.TxPdos[3] = { FALSE, 0, 0x1403, 0xFF };
CanOpen.SdoCommandCount = 1;
CanOpen.SdoCommands[0].Index = 0x6060;
CanOpen.SdoCommands[0].SubIndex = 0;
CanOpen.SdoCommands[0].Length = 1;
CanOpen.SdoCommands[0].Data[0] = 0x1;
nRet = AddModuleConfiguration(
1, // EthercatSlaveID
0x70, // LinkedDeviceID, it is CANopen device's node ID for CANopen protocol
configCANopen, // Protocol
&CanOpen // Settings
);
// configEsi
AddModuleConfiguration(3, (int)strlen("Sanyodenki RS2 special"), configEsi, "Sanyodenki RS2 special");
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksapi.h | ksapi.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also